package com.huike.review.mapper;

import com.huike.review.pojo.Review;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * Mybatis复习的Mapper层
 */
public interface MybatisReviewMapper {


    /**======================================================新增======================================================**/
    @Insert("INSERT INTO mybatis_review (name,age,sex) values (#{name},#{age},#{sex})")
    int saveData(@Param("name") String name, @Param("age") Integer age, @Param("sex") String sex);
    @Insert("insert into mybatis_review (name, age,sex) values (#{name},#{age},#{sex})")
    int addData(Review review);
    /**======================================================删除======================================================**/

    @Delete("delete from mybatis_review where id = #{id}")
    int remove(Long id);
    /**======================================================修改======================================================**/
     @Update("update mybatis_review set name =#{name}, age =#{age} ,sex =#{sex} where id = #{id}")
    void update(Review review);
    /**======================================================简单查询===================================================**/

      @Results({@Result (property = "createBy",column = "create_by"),
              @Result (property = "updateBy",column = "update_user")}
      )
      @Select("select * from mybatis_review")
       List<Review> getDataPage();

     @Results(@Result (property = "createBy",column = "create_by"))
     @Select("select * from  mybatis_review where id = #{id}")
    Review getByid(Long id);

}
